package cn.gson.crm.model.pojos;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "Exchange_goods")
public class ExchangeGoods {
    private long excId;
    private String excNumber;
    private Long excCharge;
    private String excReason;
    private String excDesc;
    private Long excAmount;
    private Timestamp excTime;
    private Long ereApprover;
    private Long excMoney;
    private String ecrState;
    private Customer customerByCustomerId;
    private Order orderByOrderId;
    private List<ReplacementDetails> replacementDetails;
    private Employee employee;
    private Employee employee2;

    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name = "exc_charge",insertable = false,updatable = false)//设置在article表中的关联字段(外键)
    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }
    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name = "ere_approver",insertable = false,updatable = false)//设置在article表中的关联字段(外键)
    public Employee getEmployee2() {
        return employee2;
    }

    public void setEmployee2(Employee employee2) {
        this.employee2 = employee2;
    }
    @Column(name="EXC_MONEY")
    public Long getExcMoney() {
        return excMoney;
    }

    public void setExcMoney(Long excMoney) {
        this.excMoney = excMoney;
    }

    @OneToMany(mappedBy = "exchangeGoods")
    public List<ReplacementDetails> getReplacementDetails() {
        return replacementDetails;
    }

    public void setReplacementDetails(List<ReplacementDetails> replacementDetails) {
        this.replacementDetails = replacementDetails;
    }
    @ManyToOne
    @JoinColumn(name = "order_id", referencedColumnName = "order_id")
    public Order getOrderByOrderId() {
        return orderByOrderId;
    }

    public void setOrderByOrderId(Order orderByOrderId) {
        this.orderByOrderId = orderByOrderId;
    }

    @Id
    @Column(name = "exc_id")
    @GeneratedValue(generator = "seq",strategy = GenerationType.SEQUENCE)
    //定义一个序列生成器
    @SequenceGenerator(name = "seq",sequenceName = "crm",
            initialValue = 1,allocationSize = 1)
    public long getExcId() {
        return excId;
    }

    public void setExcId(long excId) {
        this.excId = excId;
    }

    @Basic
    @Column(name = "exc_number")
    public String getExcNumber() {
        return excNumber;
    }

    public void setExcNumber(String excNumber) {
        this.excNumber = excNumber;
    }

    @Basic
    @Column(name = "exc_charge")
    public Long getExcCharge() {
        return excCharge;
    }

    public void setExcCharge(Long excCharge) {
        this.excCharge = excCharge;
    }

    @Basic
    @Column(name = "exc_Reason")
    public String getExcReason() {
        return excReason;
    }

    public void setExcReason(String excReason) {
        this.excReason = excReason;
    }

    @Basic
    @Column(name = "exc_desc")
    public String getExcDesc() {
        return excDesc;
    }

    public void setExcDesc(String excDesc) {
        this.excDesc = excDesc;
    }

    @Basic
    @Column(name = "exc_amount")
    public Long getExcAmount() {
        return excAmount;
    }

    public void setExcAmount(Long excAmount) {
        this.excAmount = excAmount;
    }

    @Basic
    @Column(name = "exc_time")
    public Timestamp getExcTime() {
        return excTime;
    }

    public void setExcTime(Timestamp excTime) {
        this.excTime = excTime;
    }

    @Basic
    @Column(name = "ere_approver")
    public Long getEreApprover() {
        return ereApprover;
    }

    public void setEreApprover(Long ereApprover) {
        this.ereApprover = ereApprover;
    }

    @Basic
    @Column(name = "ecr_state")
    public String getEcrState() {
        return ecrState;
    }

    public void setEcrState(String ecrState) {
        this.ecrState = ecrState;
    }



    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }

    @Override
    public String toString() {
        return "ExchangeGoods{" +
                "excId=" + excId +
                ", excNumber='" + excNumber + '\'' +
                ", excCharge=" + excCharge +
                ", excReason='" + excReason + '\'' +
                ", excDesc='" + excDesc + '\'' +
                ", excAmount=" + excAmount +
                ", excTime=" + excTime +
                ", ereApprover=" + ereApprover +
                ", excMoney=" + excMoney +
                ", ecrState='" + ecrState + '\'' +
                ", customerByCustomerId=" + customerByCustomerId +
                ", orderByOrderId=" + orderByOrderId +
                ", replacementDetails=" + replacementDetails +
                ", employee=" + employee +
                ", employee2=" + employee2 +
                '}';
    }
}
